home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 145 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  3.2 KB

  1. From: kanze@gabi.gabi-soft.fr (J. Kanze)
  2. Message-ID: <KANZE.96Jan26134840@gabi.gabi-soft.fr>
  3. X-Original-Date: 26 Jan 1996 12:48:40 GMT
  4. Path: in2.uu.net!bounce-back
  5. Date: 26 Jan 96 14:08:41 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Re: auto_ptr again
  9. Organization: GABI Software, Sarl.
  10. References: <4djrn4$js1@engnews1.Eng.Sun.COM> <AB29a1naHH@qsar.chem.msu.su>
  11. In-Reply-To: "Eugene Radchenko"'s message of Thu, 25 Jan 1996 05:31:18 GMT
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBFAgUBMQjgeOEDnX0m9pzZAQE4HwF8CeI7L1ME2TGOmjGwb8xUwvg7cADovGqb
  14.     2xxHDQ9Gca20dUWhUaYrcDJzGfqMG0sq
  15.     =GyZM
  16.  
  17. In article <AB29a1naHH@qsar.chem.msu.su> "Eugene Radchenko"
  18. <eugene@qsar.chem.msu.su> writes:
  19.  
  20. > The fact is, multiauto_ptrs can be used in every place where singleauto_ptr
  21. > can. The only possible drawback is the overhead in performance (negligible
  22. > as compared to memory allocation - especially for list implementation) and
  23. > storage (not so terrible as current compilers are not likely to put
  24. > single_ap in register anyway).
  25.  
  26. By multiauto_ptr's, I presume you are refering to what are sometimes
  27. called counted_ptr's.  If so, I explained the problems (at the
  28. standardization level) in another posting.
  29.  
  30. > On the other hand, single_ap can't be put in
  31. > STL container, can't be returned from the function, etc. Thus, the only its
  32. > possible use is ensuring that temporarily allocated object is deleted on
  33. > exception throw. (I would appreciate J.Kanze explaining the workarounds he
  34. > mentioned in another follow-up).
  35.  
  36. The only `work-arounds' I can remember discussing are at the
  37. implementation or standardization level.  I have my own implementation
  38. of auto_ptr, which I use in containers (not STL, but the same basic
  39. principal), as return values from functions, etc., etc.  In my case, I
  40. simply declared the parameter to operator= to be a const reference
  41. (instead of non-const), and cast away const in the implementation.  It's
  42. not very pretty, but it gives me the single owner semantics defined in
  43. the standard, while still allowing me to use the pointer in common
  44. circumstances.  
  45.  
  46. There was a long discussion on this subject here not too long ago, and I
  47. don't really want to open it up again.  I think it would be safe to
  48. assume that enough of the standards committee members read this forum
  49. (the chairman is, after all, one of the moderators), and that the
  50. results of this previous discussion are being considered in the
  51. standards committee.  This is certainly not the most important thing the
  52. committee has to attend to, decisions in such a committee take time, and
  53. there is not a `draft standard of the week'; in these conditions, I
  54. think it only fair to give the committee time to act before re-opening
  55. the question.
  56. -- 
  57. James Kanze           (+33) 88 14 49 00          email: kanze@gabi-soft.fr
  58. GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
  59. Conseils, itudes et rialisations en logiciel orienti objet --
  60.               -- A la recherche d'une activiti dans une region francophone
  61. ---
  62. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  63.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  64.   is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
  65.